package com.enjoyor.soa.traffic.core.tsms.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.enjoyor.soa.traffic.core.tsms.domain.RoutePoint;
import com.enjoyor.soa.traffic.core.tsms.mapper.IRoutePointMapper;
import com.enjoyor.soa.traffic.core.tsms.service.IRoutePointService;
import com.enjoyor.soa.traffic.frame.logger.IPubLogMapper;
import com.enjoyor.soa.traffic.frame.support.mybatis.mapper.impl.BaseMapper;
import com.enjoyor.soa.traffic.util.enums.log.LogInfoDic;
import com.enjoyor.soa.traffic.util.helper.TimeHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
@Service
@Transactional
@SuppressWarnings("rawtypes")
public class RoutePointService extends BaseMapper implements IRoutePointService{

	@Autowired
	private IRoutePointMapper iRoutePointMapper;
	
	@Autowired
	private IPubLogMapper iPubLogMapper;
	
	@Override
	public Page getRoutePointPage(Page page,String routeId,String routePointId,String routePointName) {
		// TODO Auto-generated method stub
		Map mapBean = new HashMap<>();
		mapBean.put("routeId",routeId);
		mapBean.put("pointId",routePointId );
		mapBean.put("pointName", routePointName);
		page.setMapBean(mapBean);
		return iRoutePointMapper.getToutePointPage(page);
	}

	@Override
	public List<RoutePoint> getRoutePointList(String routeId,String routePointId,String routePointName) {
		// TODO Auto-generated method stub\
		Map map = new HashMap<>();
		map.put("routeId",routeId);
		map.put("pointId",routePointId );
		map.put("pointName", routePointName);
		return iRoutePointMapper.getRoutePointList(map);
	}

	@Override
	public void insert(RoutePoint routePoint, String personName) {
		// TODO Auto-generated method stub
		routePoint.setPointId("P"+ TimeHelper.getUniqueString());
		iRoutePointMapper.insert(routePoint);
		iPubLogMapper.saveNoramlLogInfo(personName, null,LogInfoDic.LOG_TRANSTYPE_ENUM.TRANSTYPE_INSERT.getCode(),
                String.format("添加途径点:{%s} 操作成功!", new Object[] { routePoint.getId() }),
                LogInfoDic.LOG_MODULAR_ENUM.TSMS_COMMON_ROUTE_MANAGEMENT.getMessage());
	}

	@Override
	public void delete(String pointId, String routeId, String personName) {
		Map<String, Object> map = new HashMap<>();
		map.put("pointId", pointId);
		map.put("routeId", routeId);
		iRoutePointMapper.deleteRoutePoint(map);
		iPubLogMapper.saveNoramlLogInfo(personName, null,LogInfoDic.LOG_TRANSTYPE_ENUM.TRANSTYPE_DELETE.getCode(),
                String.format("删除常备线路:{%s} 操作成功!", new Object[] { pointId}),
                LogInfoDic.LOG_MODULAR_ENUM.TSMS_COMMON_ROUTE_MANAGEMENT.getMessage());
		// TODO Auto-generated method stub
	}

}
